//
// Created by HP on 2024/3/16.
//

#include "aurora_menu.h"


Aurora_Menu::Aurora_Menu(LCD_Driver *lcd_s,Aurora_Font *font_s){
    _lcd = lcd_s;
    _font = font_s;
}

void Aurora_Menu::add_Driver(LCD_Driver *lcd_s,Aurora_Font *font_s){
    _lcd = lcd_s;
    _font = font_s;
}

void Aurora_Menu::addLCD_Driver(LCD_Driver *lcd_s){
    _lcd = lcd_s;
}

void Aurora_Menu::addFont_Driver(Aurora_Font *font_s){
    _font = font_s;
}


void Aurora_Menu::Init(){
    title_label.set_font_driver(_font);
    title_label.set_lcd_driver( _lcd);
    title_label.set_font_size(Aurora_Font::font_size_big);
    title_label.set_pos(90,0);
    title_label.set_text("AuroraFOC");
    title_label.show();

    menu_label[0].set_font_driver(_font);
    menu_label[0].set_lcd_driver(_lcd);
    menu_label[0].set_font_size(Aurora_Font::font_size_middle);
    menu_label[0].set_pos(30,55);
    menu_label[0].set_text("模式选择");
    menu_label[0].set_select(ENABLE);
    menu_label[0].show();


    menu_label[1].set_font_driver(_font);
    menu_label[1].set_lcd_driver(_lcd);
    menu_label[1].set_font_size(Aurora_Font::font_size_middle);
    menu_label[1].set_pos(190,55);
    menu_label[1].set_text("波形显示");
    menu_label[1].show();

    menu_label[2].set_font_driver(_font);
    menu_label[2].set_lcd_driver(_lcd);
    menu_label[2].set_font_size(Aurora_Font::font_size_middle);
    menu_label[2].set_pos(30,110);
    menu_label[2].set_text("详细信息");
    menu_label[2].show();

    menu_label[3].set_font_driver(_font);
    menu_label[3].set_lcd_driver(_lcd);
    menu_label[3].set_font_size(Aurora_Font::font_size_middle);
    menu_label[3].set_pos(190,110);
    menu_label[3].set_text("显示待机");
    menu_label[3].show();

    selelct_index = 1;
}

void Aurora_Menu::switch_next_label(){
    selelct_index = (selelct_index == MAX_INDEX) ? selelct_index : selelct_index+1;
    menu_label[selelct_index-2].set_select(DISABLE);
    menu_label[selelct_index-1].set_select(ENABLE);
    menu_label[selelct_index-2].show();
    menu_label[selelct_index-1].show();

}
void Aurora_Menu::switch_prev_label(){
    selelct_index = (selelct_index == 1) ? 1 : selelct_index-1;
    menu_label[selelct_index].set_select(DISABLE);
    menu_label[selelct_index-1].set_select(ENABLE);

    menu_label[selelct_index].show();
    menu_label[selelct_index-1].show();
}


uint8_t Aurora_Menu::get_curr_menu(){
    return selelct_index;
}